package net.huanger.gametools.mapeditor.ui.impl;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import net.huanger.gametools.mapeditor.ui.IDiv;
import net.huanger.gametools.mapeditor.ui.MUtils;
import net.huanger.gametools.mapeditor.ui.Operate;

public abstract class AbstractOperate implements Operate, IDiv
{
  private boolean show;
  private BufferedImage image;
  private Graphics g;
  protected int mapRow,mapColumn;
  public AbstractOperate(int row,int column){
    this.show=true;
    this.mapRow=row;
    this.mapColumn=column;
    image=new BufferedImage(column*MUtils.MAP_UNIT,row*MUtils.MAP_UNIT, BufferedImage.TYPE_INT_ARGB);
  }
  @Override
  public boolean isShow()
  {
    return show;
  }
  @Override
  public void isShow(boolean show)
  {
    this.show=show;
  }




  @Override
  public IDiv getMapDiv()
  {
    return this;
  }
  @Override
  public void drawDiv(Graphics g)
  {
    g.drawImage(image, 0, 0, null);
  }
  protected Graphics getGraphics(){
    if(g==null){
      g=image.getGraphics();
    }
    return g;
  }
  protected BufferedImage getImage(){
    return image;
  }
}
